package com.ruoyi.system.domain.wrapper.view;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.eic.framework.core.domain.BaseEntityWrapperV;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.domain.dao.SysDept;
import com.ruoyi.system.domain.view.SysDeptVo;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 部门前端实体包装
 *
 * @author 尹国春
 * @date 2022-07-25
 */
public class SysDeptWrapperV extends BaseEntityWrapperV<SysDept, SysDeptVo> {

    private static SysDeptWrapperV wrapperV=null;
    //示例代码
    //private static IDemoDeptService demoDeptService;
    private SysDeptWrapperV(){
    }

    public static SysDeptWrapperV build(){
        if(wrapperV==null){
            //示例代码
            //demoDeptService= SpringUtils.getBean(IDemoDeptService.class);
            //Assert.notNull(demoDeptService);
            wrapperV=new SysDeptWrapperV();
        }
        return wrapperV;
    }

    @Override
    public SysDeptVo entityVO(SysDept entity) {
        if(entity==null){
            return new SysDeptVo();
        }
        SysDeptVo vo = BeanUtil.copyProperties(entity,SysDeptVo.class);
        //示例代码
        //vo.setDeptName(getFieldValue(demoDeptService,entity.getDeptId(),DemoDept::getDepartName));
        return vo;
    }

    /*示例代码
    @Override
    public List<SysDeptVo> listVO(List<SysDept> list) {
        List<SysDeptVo> voList=list.stream().map(user -> BeanUtil.copyProperties(user,SysDeptVo.class)).collect(Collectors.toList());
        copyForeignKeyData(voList,SysDeptVo::getDeptId,SysDeptVo::setDeptName,demoDeptService,DemoDept::getDepartName);
        return voList;
    }
    */
}